# QToolBar(工具栏）
from PyQt5.QtWidgets import QToolBar, QMenuBar, QMenu, QAction, QLineEdit, QStyle, QFormLayout, QVBoxLayout, QWidget, \
    QApplication, QHBoxLayout, QPushButton, QMainWindow, QGridLayout, QLabel, QStatusBar
from PyQt5.QtGui import QIcon, QPixmap

import sys


class WindowClass(QMainWindow):

    def __init__(self, parent=None):
        super(WindowClass, self).__init__(parent)
        self.layout = QVBoxLayout()
        self.resize(200, 300)
        # 菜单栏
        menuBar = self.menuBar()
        menu = menuBar.addMenu("File")
        action = QAction(QIcon("./image/save.ico"), "New Project", self)
        menu.addAction(action)

        menu2 = menu.addMenu("Add to ...")
        menu2.addAction(QAction("workspace edit...", self))

        # 工具栏
        tool = self.addToolBar("File")
        # edit=QAction(QIcon("./image/save.ico"),"刷新",self)
        edit = QAction(QIcon("./img/save.ico"), "save", self)
        tool.addAction(edit)

        wifi = QAction(QIcon(QPixmap("./img/wifi.png")), "wifi", self)
        tool.addAction(wifi)
        tool.actionTriggered[QAction].connect(self.toolBtnPressed)

        # 状态栏
        self.statusbar = QStatusBar()
        self.setStatusBar(self.statusbar)

    def toolBtnPressed(self, qaction):
        print("pressed too btn is", qaction.text())
        # 设置状态栏信息
        self.statusbar.showMessage(qaction.text(), 5000)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = WindowClass()
    win.show()
    sys.exit(app.exec_())
